package com.example.administrator.appstpremvpdemo.presenter;

import com.example.administrator.appstpremvpdemo.contract.AppListContract;


/**
 * Created by Administrator on 2017/12/4.
 */

public abstract class NetExceptionPresenter<T> implements AppListContract.Presenter<T> {

    public AppListContract.View mView;

    public NetExceptionPresenter(AppListContract.View view, String url) {
        this.mView = view;
    }

    @Override
    public void handleRequestException(Exception exception) {

//        if (exception instanceof NetworkError) {// 网络不好
//            //Toast.makeText(mActivity, "请检查网络", Toast.LENGTH_SHORT).show();
//
//        } else if (exception instanceof TimeoutError) {// 请求超时
//            //Toast.makeText(mActivity, "请求超时", Toast.LENGTH_SHORT).show();
//        } else if (exception instanceof UnKnownHostError) {// 找不到服务器
//            //Toast.makeText(mActivity, "找不到服务器", Toast.LENGTH_SHORT).show();
//        } else if (exception instanceof URLError) {// URL是错的
//            //Toast.makeText(mActivity, "URL是错的", Toast.LENGTH_SHORT).show();
//        } else if (exception instanceof NotFoundCacheError) {
//            // 这个异常只会在仅仅查找缓存时没有找到缓存时返回
//            // 没有缓存一般不提示用户，如果需要随你。
//        } else {
//            //Toast.makeText(mActivity, "未知错误", Toast.LENGTH_SHORT).show();
//        }

        mView.showloaderrotips(exception.getMessage());
    }
}
